package com.googlecode.spreadit.bean;

import java.io.Serializable;

/**
 * This is an abstraction for all kinds of {@link Message}s. I.e., incoming SMS
 * messages, e-mails, etc. are first wrapped into this mediation class.
 * 
 * @author Markus L. Dechert (markus.dechert@googlemail.com)
 */
public class Message implements Serializable {

	/**
	 * Generated serialization ID.
	 */
	private static final long serialVersionUID = 8871459812779602301L;

	private String subject;
	private String body;
	private String sender;
	private String recipient;
	private SpreadChannel incomingChannel;

	public Message(String subject, String body, String sender,
			String recipient, SpreadChannel incomingChannel) {
		this.subject = subject;
		this.body = body;
		this.sender = sender;
		this.recipient = recipient;
		this.incomingChannel = incomingChannel;
	}

	public Message(String subject, String body, String sender,
			SpreadChannel incomingChannel) {
		this(subject, body, sender, null, incomingChannel);
	}

	public SpreadChannel getIncomingChannel() {
		return incomingChannel;
	}

	public void setIncomingChannel(SpreadChannel incomingChannel) {
		this.incomingChannel = incomingChannel;
	}

	/**
	 * The subject of the message. May be empty in case of messages that only
	 * consist of a body.
	 * 
	 * @param subject
	 *            the subject of the message.
	 */
	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	/**
	 * The payload of the message.
	 * 
	 * @param body
	 *            of the message.
	 */
	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	/**
	 * An ID of the sender. This might by a number or a alphanumeric string.
	 * 
	 * @param sender
	 *            is some kind of ID of the sender.
	 */
	public String getSender() {
		return sender;
	}

	public void setSender(String sender) {
		this.sender = sender;
	}

	/**
	 * The anticipated recipient of the incoming message. This might be a list
	 * separated by <tt>;</tt> in case of e.g. e-mails that have been sent to
	 * multiple recipients.
	 * 
	 * @param recipient
	 *            the ID of the receiver or a list of IDs separated by
	 *            <tt>;</tt>
	 */
	public String getRecipient() {
		return recipient;
	}

	public void setRecipient(String recipient) {
		this.recipient = recipient;
	}

}
